import request from "@/utils/request";

import type {
  TrademarkList,
  TrademarkItem,
  TrademarkReq,
} from "./model/trademarkModel";

const enum Api {
  getTrademarkList = "/admin/product/baseTrademark",
  addTrademark = "/admin/product/baseTrademark/save",
  updateTrademark = "/admin/product/baseTrademark/update",
  delTrademark = "/admin/product/baseTrademark/remove",
  getAllTrademarkList = "/admin/product/baseTrademark/getTrademarkList",
}

export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, TrademarkReq>(
    Api.getTrademarkList + `/${page}/${limit}`
  );
};

export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarkList>(Api.getAllTrademarkList);
};

export const addTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.addTrademark, {
    tmName,
    logoUrl,
  });
};

export const updateTrademarkApi = (data: TrademarkItem) => {
  return request.put<any, null>(Api.updateTrademark, data);
};

export const delTrademarkApi = (id: number) => {
  return request.delete<any, null>(Api.delTrademark + `/${id}`);
};
